package math;

/**
 * 给你两个数 hour 和 minutes 。请你返回在时钟上，由给定时间的时针和分针组成的较小角的角度（60 单位制）。
 * <p>
 * 示例 1：
 * 输入：hour = 12, minutes = 30
 * 输出：165
 * <p>
 * 示例 2：
 * 输入：hour = 3, minutes = 30
 * 输出；75
 * <p>
 * 示例 3：
 * 输入：hour = 3, minutes = 15
 * 输出：7.5
 * <p>
 * 示例 4：
 * 输入：hour = 4, minutes = 50
 * 输出：155
 * <p>
 * 示例 5：
 * 输入：hour = 12, minutes = 0
 * 输出：0
 *
 * @author Jisheng Huang
 * @version 20250426
 */
public class AngleBetweenClock_1344 {
    /**
     * Calculate the angle between hour and minutes
     *
     * @param hour    the number for the hour
     * @param minutes the number for the minute
     * @return the angle difference between hour and minute
     */
    public static double angleClock(int hour, int minutes) {
        int oneMinAngle = 6;
        int oneHourAngle = 30;

        double minutesAngle = oneMinAngle * minutes;
        double hourAngle = (hour % 12 + minutes / 60.0) * oneHourAngle;

        double diff = Math.abs(hourAngle - minutesAngle);

        return Math.min(diff, 360 - diff);
    }

    public static void main(String[] args) {
        System.out.println(angleClock(12, 30));
        System.out.println(angleClock(3, 30));
        System.out.println(angleClock(3, 15));
        System.out.println(angleClock(4, 50));
        System.out.println(angleClock(12, 0));
        System.out.println(angleClock(3, 16));
    }
}
